package com.jsz.peini.server.thread;

import java.util.List;

import org.apache.log4j.Logger;

import com.jsz.peini.common.util.FileUtils;
import com.jsz.peini.common.util.UploadQN;
import com.jsz.peini.redis.base.RedisConstants;
import com.jsz.peini.redis.base.RedisUtil;
import com.jsz.peini.redis.base.SerializeUtil;
import com.jsz.peini.vo.SmallImgVo;


public class SquareBigImgThread extends Thread{
	
	Logger logger = Logger.getLogger(SquareBigImgThread.class);
	
	public void init(){
		this.start();
	}
	
	@Override
	public void run() {
		super.run();
		
		while(true)
		{
			try {
				List<byte[]> list = RedisUtil.brpop(RedisConstants.IMG_SQUARE_BIG.getBytes());
				if(list.size() > 1){
					byte [] img = list.get(1);
					SmallImgVo imgVo = (SmallImgVo)SerializeUtil.unserialize(img);
					UploadQN qn = new UploadQN();
					qn.upload(imgVo.getFile(), imgVo.getBigName());
				}
				
				Thread.sleep(1);
			} catch (Exception e1) {
				e1.printStackTrace();
				logger.info("fail", e1);
			}
		}
		
	}
	
}